package com.storlead.shiro.util;

import com.alibaba.fastjson.JSON;

/**
 * @Author: Timo
 * @Date: 2019/2/12 11:39
 * @Description: 返回实体类工具
 */
public class Result<T> {
    private int code;
    private String msg;
    private T data;
    private boolean logined = false;
    private boolean status = false;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public boolean isLogined() {
        return logined;
    }

    public void setLogined(boolean logined) {
        this.logined = logined;
    }

    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public Result() {

    }

    public Result(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(int code, String msg, T data, boolean logined, boolean status) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.logined = logined;
        this.status = status;
    }

    public Result(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.logined = true;
        this.status = true;
    }

    public Result(int code) {
        this.code = code;
        if (code == 1){
            this.msg = "成功";
            this.data = (T) "成功";
        }else {
            this.msg = "成功";
            this.data = (T) JSON.parse("失败");
        }

        this.logined = true;
        this.status = true;
    }


}
